


class ScorePanel {
    score = 0 ;
    level = 1 ;
    maxLevel = 10 ;  // 最大等级
    upNumber = 10 ; // 每10分升一级
    scoreEle : HTMLElement;
    levelEle : HTMLElement;
    constructor(maxLevel: number , upNumber: number ) {
        this.maxLevel = maxLevel;
        this.upNumber = upNumber ;
        this.scoreEle = document.getElementById('score')!;
        this.levelEle = document.getElementById('level')!;
    }

    // 加分
    addScore() {
        this.scoreEle.innerHTML = ++ this.score + '';
        if (this.score % 10 === 0) {
            this.levelUp() ;
        }
    }
    levelUp(){
        if (this.level >= 10 ) {
            return ;
        }
        this.levelEle.innerHTML = ++ this.level + '' ;
    }
}

export default ScorePanel;